package droid.net.playcabbage.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import droid.net.playcabbage.activity.CabbageActivity;
import droid.net.playcabbage.xxx.NewList;

import net.droid.cabbagedroid.R;

import android.os.Bundle;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.SimpleAdapter;

public class MainActivity extends CabbageActivity {
	
	 int itid;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		//		Intent i = new Intent(getApplicationContext(), NewList.class);
		//		startActivityForResult(i, 100); // 100 is some code to identify the returning result
		//		
		//		
		//		// Set the Action Bar title
		//		ActionBar actionBar = getActionBar();
		//		actionBar.setTitle("TITLE");
		//
		//		// Set up the Action Bar home/icon button
		//		//actionBar.setHomeLogo(R.drawable.icon);
		////		Intent homeIntent = new Intent(Intent.ACTION_VIEW);
		////		homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		////		homeIntent.setClassName(this, MainActivity.class.getName());
		////		actionBar.setHomeAction(new ActionBar.IntentAction(this, homeIntent, null));
		//
		//		// Add an Action Bar button
		//		Intent actionIntent = new Intent(Intent.ACTION_VIEW);
		//		actionIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		//		actionIntent.setClassName(this, NewList.class.getName());
		//		actionIntent.
		//		actionBar.
		//		actionBar.addAction(new ActionBar.IntentAction(this, actionIntent));
		//		

		//		String s[] = {"one","two"};
		//		
		//		ActionBar ab = getActionBar();
		//		ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
		//		ab.setListNavigationCallbacks(new ArrayAdapter<String>(this, android.R.layout.activity_list_item,s),new ActionBar.OnNavigationListener()
		//        {
		//            @Override
		//            public boolean onNavigationItemSelected(int itemPosition, long itemId)
		//            {
		//                final String fragmentTag = "fragment-" + itemPosition;
		//
		//                // to prevent fragment re-selection and loosing early saved state
		//                if (getFragmentManager().findFragmentByTag(fragmentTag) != null)
		//                {
		//                    return true;
		//                }
		//
		//                final Fragment fragment = fragmentProviders[itemPosition].get();
		//                getFragmentManager().beginTransaction().
		//                    replace(android.R.id.content, fragment, fragmentTag).
		//                    commit();
		//                return true;
		//            }
		//        });

		//OptionsMenu om = new OptionsMenu();

		//		String s[] = {"one","two"};
		//		//Tab t1 = new Tab();
		//		ActionBar ab = getActionBar();
		//		ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
		//		this.geto
		//		
		//		final List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
		//		Object st = "New list";
		//			Map<String, Object> map = new HashMap<String, Object>();
		////			map.put( "title", getString( R.string.frag1 ) );
		//			map.put( "title", st );
		//			map.put( "fragment", Activity.( this, 
		//				    NewList.class.getName() ));
		////			map.put( "fragment", Fragment.instantiate( this, 
		////			    NewList.class.getName() ));
		//			data.add( map );
		////			map = new HashMap<String, Object>();
		////			map.put( "title", getString( R.string.frag2 ) );
		////			map.put( "fragment", Fragment.instantiate( this, 
		////			    Fragment2.class.getName() ));
		////			data.add( map );
		//			SimpleAdapter adapter = new SimpleAdapter( this, data,
		//			    android.R.layout.simple_spinner_dropdown_item,
		//			    new String[] { "title" }, 
		//			    new int[] { android.R.id.text1 } );
		//		
		////		final List<Map<String, Object>> data = 
		////			    new ArrayList<Map<String, Object>>();
		////			Map<String, Object> map = new HashMap<String, Object>();
		//////			map.put( "title", getString( R.string.frag1 ) );
		////			map.put( "title", getString( "New List" ) );
		////			map.put( "fragment", Fragment.instantiate( this, 
		////			    NewList.class.getName() ));
		////			data.add( map );
		//////			map = new HashMap<String, Object>();
		//////			map.put( "title", getString( R.string.frag2 ) );
		//////			map.put( "fragment", Fragment.instantiate( this, 
		//////			    Fragment2.class.getName() ));
		//////			data.add( map );
		////			SimpleAdapter adapter = new SimpleAdapter( this, data,
		////			    android.R.layout.simple_spinner_dropdown_item,
		////			    new String[] { "title" }, 
		////			    new int[] { android.R.id.text1 } );
	}

	@Override
	public void buildList(String s) {
		// TODO Auto-generated method stub
		
	}

//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		// Inflate the menu; this adds items to the action bar if it is present.
//
////		Intent iiList[] = new Intent[1];
////		iiList[0] = new Intent(getApplicationContext(), NewList.class);
//		//		MenuItem mmList[] = new MenuItem[1];
//		//		mmList[0] = MenuItem.
//
//		Intent i = new Intent(getApplicationContext(), NewList.class);
//		//startActivityForResult(i, 100); // 100 is some code to identify the returning result
//
//		//menu.addIntentOptions(Menu.NONE, Menu.NONE, Menu.NONE, this.getComponentName(), iiList, null, 0, null);		
//
//
//		//menu.addIntentOptions(Menu.NONE. Menu.NONE, Menu.NONE, this.getComponentName(), null, intent, flags, outSpecificItems)
//
//		//		menu.addIntentOptions(1, 1, 1, null, null, i, null, null);
//		//		menu.add("Option1");
//		//        menu.add("Option2");
//		//        menu.add("Option3");
//		menu.add("List");
//		//itid = menu.getItem(0).getItemId();
//		Log.i(NewList.class.getName(),"XXXXXXXX" + itid);
//		menu.getItem(0).setIntent(i);
//		getMenuInflater().inflate(R.menu.cabbagemenu, menu);
//
//		//		String s[] = {"one","two"};
//		//		getMenuInflater().inflate(R.menu.main, s);
//		//		getMenuInflater().inflate(R.menu.main, menu);
//		//		menu.add("bla");
//		return true;
//	}

//	public boolean onOptionsItemSelected(MenuItem item){
//		final int xx = itid;
//		switch(item.getItemId()){
//		case xx:
//			Intent i = new Intent(getApplicationContext(), NewList.class);
//			startActivityForResult(i, 100); // 100 is some code to identify the returning result
//			break;
//		case 2:
//			Intent i2 = new Intent(getApplicationContext(), NewList.class);
//			startActivityForResult(i2, 100); // 100 is some code to identify the returning result
//			break;
//		}
//		return true;
//	}

}
